f = open('18num','r')
data = []
largest = 0 

for line in f:
	data.append([int(x) for x in line.split(" ")])

def getl(x,y):
	if x < len(data)-1:
		temp1 = getl(x+1,y) + data[x][y]
		temp2 = getl(x+1,y+1) + data[x][y]
		return max(temp1,temp2)
	else:
		return data[x][y]

print(getl(0,0))